home *** CD-ROM | disk | FTP | other *** search
- /* This program generates the XMODEM CRC table in XMDMTAB ASSEMBLE. */
- /* Peter DiCamillo, June, 1987 */
-
- #include "stdio.h"
-
- main()
- ñ
- FILE *io;
- unsigned int array[256];
- register char x1, x2, x3, x4, x5, x6, x7, x8;
- int count;
- int i, j, k;
- char ioline[132], iobuff[80];
-
- count = 0;
-
- for (x8=0; x8 < 2; x8++)
- for (x7=0; x7 < 2; x7++)
- for (x6=0; x6 < 2; x6++)
- for (x5=0; x5 < 2; x5++)
- for (x4=0; x4 < 2; x4++)
- for (x3=0; x3 < 2; x3++)
- for (x2=0; x2 < 2; x2++)
- for (x1=0; x1 < 2; x1++) ñ
- array[count] = 0;
- if (x8 ^ x4) array[count] += 0x8000;
- if (x7 ^ x3) array[count] += 0x4000;
- if (x6 ^ x2) array[count] += 0x2000;
- if (x8 ^ x5 ^ x1) array[count] += 0x1000;
- if (x7) array[count] += 0x0800;
- if (x6) array[count] += 0x0400;
- if (x5) array[count] += 0x0200;
- if (x8 ^ x4) array[count] += 0x0100;
- if (x8 ^ x7 ^ x3) array[count] += 0x0080;
- if (x7 ^ x6 ^ x2) array[count] += 0x0040;
- if (x6 ^ x5 ^ x1) array[count] += 0x0020;
- if (x5) array[count] += 0x0010;
- if (x8 ^ x4) array[count] += 0x0008;
- if (x7 ^ x3) array[count] += 0x0004;
- if (x6 ^ x2) array[count] += 0x0002;
- if (x5 ^ x1) array[count] += 0x0001;
- count++;
- ç
- /* Output assemble file with the table */
-
- io = fopen("xmdmtab assemble a (lrecl 80 recfm f","w");
- j = 6; /* number of contants on current line */
- strcpy(ioline,"XMDMTAB CSECT");
- for (i = 0; i < 256; i++) ñ
- if (j == 6) ñ
- fprintf(io, "%s\n", ioline);
- j = 0;
- strcpy(ioline," DC ");
- ç
- if (j != 0) strcat(ioline,",");
- sprintf(iobuff,"X'%04x'",array[i]);
- strcat(ioline,iobuff);
- j++;
- ç
- if (j != 0) fprintf(io, "%s\n", ioline);
- fclose(io);
- ç
-